package local

import (
	"github.com/sirupsen/logrus"
	"sync"
	"github.com/ingopansa/userinfoservice/tokenprovider"
	"github.com/ingopansa/userinfoservice/model"
)

type Config struct {
}

type localTokenProvider struct {
	mu sync.Mutex

	//clients         map[string]storage.Client
	accessTokenData	  []interface{}

	logger logrus.FieldLogger
}

// New returns an in memory storage.
func New(logger logrus.FieldLogger) tokenprovider.TokenProvider {
	return &localTokenProvider{
		accessTokenData: make([]interface{},0),
		logger: logger,
	}
}

// Open always returns a new in memory storage.
func (c *Config) Open(logger logrus.FieldLogger) (tokenprovider.TokenProvider, error) {
	logger.Debugf( "Opening local token provider" )
	return New(logger), nil
}

func (c *localTokenProvider)Introspect(accessToken string)(accessTokenData model.AccessTokenData, err error){
	c.logger.Debugf("localTokenProvider.Introspect() - provided accessToken: %v", accessToken )

	accessTokenData = model.AccessTokenData{
		Sub: "INPANSA",
		Active: true,
		Scope: "openid profile email phone",
	}

	return accessTokenData, nil
}